package com.springboot.service.impl;

import com.springboot.mapper.AssistantListFormMapper;
import com.springboot.model.AssistantListFormKey;
import com.springboot.service.AssistantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class AssistantServicelmpl implements AssistantService {
    @Autowired
    private AssistantListFormMapper assistantListFormMapper;

    @Override
    public ArrayList<AssistantListFormKey> findDoctorsByID(Integer id){
        ArrayList<AssistantListFormKey> doctorList = new ArrayList<>();
        try {
            //AssistantListFormKey assistantListFormKey = new AssistantListFormKey();
//            assistantListFormKey.setAssistantId(2);
//            assistantListFormKey.setDoctorId(1);
//            Integer a = 3;
            doctorList= assistantListFormMapper.findDoctorById(id);
        }
        catch (Exception e)
        {
            System.out.println("AssistantServicelmpl-findDoctorsByID错误");
//            e.printStackTrace();
//            throw e;
        }
        finally {
            return  doctorList;
        }
    }

    @Override
    public ArrayList<AssistantListFormKey>  findAssistantByID(Integer doctorId){
        ArrayList<AssistantListFormKey> assistantListFormKeys = new ArrayList<>();
        try {
            assistantListFormKeys= assistantListFormMapper.findAssistantById(doctorId);
        }
        catch (Exception e)
        {
            System.out.println("AssistantServicelmpl-findDoctorsByID错误");
//            e.printStackTrace();
//            throw e;
        }
        finally {
            return  assistantListFormKeys;
        }
    }

    @Override
    public int deleteForm(AssistantListFormKey assistantListFormKey){
        int a=-1;
        try{
            a=assistantListFormMapper.deleteByPrimaryKey(assistantListFormKey);

        }
        catch (Exception e){
            System.out.println("assistantListFormMapper删除出错");
            e.printStackTrace();
        }
        return a;
    }

    @Override
    public int insertForm(AssistantListFormKey assistantListFormKey){
        int a=-1;
        try{
            a=assistantListFormMapper.insertSelective(assistantListFormKey);

        }
        catch (Exception e){
            System.out.println("assistantListFormMapper插入出错");
            e.printStackTrace();
        }
        return a;
    }

}
